#!/bin/bash
dld_qqvid() {
  test "$vid" -a "$fname" || { echo "empty vid or fname"; return 1; }
  echo $vid $fname
  url=`curl -s "http://vv.video.qq.com/geturl?otype=json&vid=$vid" | grep -o 'http[^"]*'`
  curl -L -C - "$url" -o "$fname.mp4"
}

page=`curl -s "$1"`
[ $# -eq 1 ] && page=`echo "$page"|grep ${1##*=}`

while read vid fname; do
    dld_qqvid
done < <(echo "$page"|grep vid=|cut -d'"' -f 4,8|tr '"' ' ')
